package com.jy.api.dao;

import com.jy.api.domain.Withdraw;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by xiaohua on 2018/11/22.
 */
public interface WithdrawDao extends CrudRepository<Withdraw,Integer> {

    Page<Withdraw> findByStoreIdOrderByAddTimeDesc(String storeId, Pageable pageable);


    Page<Withdraw> findAll(Pageable pageable);

    @Query(value = " SELECT ifnull(SUM(`amount`),0)   FROM `withdraw` WHERE `store_id` =?", nativeQuery = true)
    BigDecimal findByStoreId(String storeId);









}
